﻿using System;
using System.Linq;
using System.Linq.Expressions;
using ASPItalia.ModelVirtualCasting.Common;
using ASPItalia.ModelVirtualCasting.ObjectModel;
using System.Collections.Generic;

namespace ASPItalia.ModelVirtualCasting.Fake
{
    public class CandidateRepository : BaseRepository<ICandidateRepository>, ICandidateRepository
    {
        private List<Candidate> list = new List<Candidate>();

        public CandidateRepository()
        {
            var candidate = new Candidate();
            candidate.NickName = "Cradle";
            candidate.FirstName = "Marco";
            candidate.LastName = "De Sanctis";
            candidate.BirthDate = new DateTime(1977, 7, 10);
            candidate.CanBeNaked = false;
            candidate.EmailAddress = "crad@aspitalia.com";
            candidate.Gender = "M";
            candidate.NationalityCountry = new Country { CountryID = 1, CountryName = "Italia" };
            candidate.ResidenceCountry = new Country { CountryID = 3, CountryName = "Regno Unito" };
            candidate.PhysicalProfile = new PhysicalProfile();
            candidate.PhysicalProfile.BodyHeight = 178;
            candidate.PhysicalProfile.BodySize = 52;
            candidate.PhysicalProfile.EyesColor = "Verdi";
            candidate.PhysicalProfile.HairColor = "Castani";
            candidate.PhysicalProfile.Measurement = new Measurement { ChestMeasurement = 60, WaistMeasurement = 90, HipMeasurement = 90 };
            candidate.Multimedia = new List<Multimedia>();
            candidate.Multimedia.Add(new Image { FileName = "12330.jpg" });
            candidate.Multimedia.Add(new Image { FileName = "13616.jpg" });
            candidate.Multimedia.Add(new Video { FileName = "SomeMovie.avi" });
            
            this.list.Add(candidate);

            this.list.Add(new Candidate
            {
                NickName = "Jessica",
                FirstName = "Jessica",
                LastName = "Antoni",
                Gender = "F",
                BirthDate = new DateTime(1983, 2, 5),
                ResidenceCountry = new Country { CountryID = 1, CountryName = "Italia" }
            });

            this.list.Add(new Candidate
            {
                NickName = "Carla",
                FirstName = "Carla",
                LastName = "Fresi",
                Gender = "F",
                BirthDate = new DateTime(1979, 2, 11),
                ResidenceCountry = new Country { CountryID = 1, CountryName = "Italia" }
            });

            this.list.Add(new Candidate
            {
                NickName = "Killer",
                FirstName = "Antonio",
                LastName = "Rossi",
                Gender = "M",
                BirthDate = new DateTime(1983, 1, 5),
                ResidenceCountry = new Country { CountryID = 3, CountryName = "Regno Unito" }
            });

            this.list.Add(new Candidate
            {
                NickName = "Sandrina82",
                FirstName = "Sandra",
                LastName = "Sindoni",
                Gender = "F",
                BirthDate = new DateTime(1982, 9, 22),
                ResidenceCountry = new Country { CountryID = 1, CountryName = "Italia" }
            });
        }

        public void InsertOnSubmit(Candidate entity)
        {
        }

        public void Update(Candidate entity)
        {
        }

        public void DeleteOnSubmit(Candidate entity)
        {
        }

        public void SubmitChanges()
        {
        }

        public IQueryable<Candidate> GetAll()
        {
            return this.list.AsQueryable();
        }

        public IQueryable<Candidate> Where(Expression<Func<Candidate, bool>> predicate)
        {
            return this.list.AsQueryable().Where(predicate);
        }

        public long Count(Expression<Func<Candidate, bool>> predicate)
        {
            return this.Where(predicate).Count();
        }

        public void PromoteToModel(string fiscalCode, decimal hourlyRate, string vatCode, DateTime startDate, DateTime endDate, int candidateId)
        {
            throw new NotImplementedException();
        }

        public Candidate GetByID(int id)
        {
            return this.Where(c => c.ID == id).Single();
        }

				#region IReadOnlyRepository<ICandidateRepository,Candidate> Members


				public ICandidateRepository EnableLazyLoading()
				{
					throw new NotImplementedException();
				}

				public ICandidateRepository DisableLazyLoading()
				{
					throw new NotImplementedException();
				}

				#endregion
		}
}
